<?php
session_start();
include("../includes/conn.php");
$dbconn->admin_logincheck();
$adminid=$_SESSION['adminid'];
//添加
if($_GET['act']=='add'){
	$username = $_POST['username'];
	$name=$_POST['name'];
	$password = $_POST['password'];
	$password1 = $_POST['password1'];
	$sex = $_POST['sex'];
	$province = $_POST['province'];
	$city = $_POST['city'];
	$shopname = $_POST['shopname'];
	$wx_user =$_POST['wx_user'];
	$openid = $_POST['openid'];
	$shopaddress = $_POST['shopaddress'];
	$openid = $_POST['openid'];
	$job = $_POST['job'];
	$time = date('Y-m-d H:i:s',time());
	$login_time = time();
	$selrow = $dbconn->fetch($dbconn->query("select * from ".DBQIAN."daogou where username='$username'"));
	if (!$selrow['id'])
	{
		if (!$username)
		{
			echo"<script>alert('用户名不能为空');history.go(-1);</script>";exit;
		}
		if (!$name)
		{
			echo"<script>alert('导购姓名不能为空');history.go(-1);</script>";exit;
		}
		if (!$password)
		{
			echo"<script>alert('密码不能为空');history.go(-1);</script>";exit;
		}
		if (!$password1)
		{
			echo"<script>alert('请确认密码');history.go(-1);</script>";exit;
		}
		if ($password!=$password1)
		{
			echo"<script>alert('两次输入密码不一致！');history.go(-1);</script>";exit;
		}
		if(!sex)
		{
			echo"<script>alert('请选择性别');history.go(-1);</script>";exit;
		}
		if(!$shopname)
		{
			echo"<script>alert('请输入店铺名称！');history.go(-1);</script>";exit;
		}
		if(!$shopaddress)
		{
			echo"<script>alert('请输入店铺详细地址！');history.go(-1);</script>";exit;
		}
		if(!$openid)
		{
			echo"<script>alert('如果需要领取红包请输入微信openid，如果不知道请在导购注册页面注册！');history.go(-1);</script>";exit;
		}
	//	echo 'insert into '.DBQIAN.'daogou(title,desc,time,content,url) values(\''.$title.'\',\''.$desc.'\',\''.$time.'\',\''.$content.'\',\''.$url.'\')';exit;
		$dbconn->noretquery('INSERT INTO `'.DBQIAN.'daogou` (`id`,`username`, `name`, `password`, `sex`, `shopname`,`province`, `city`, `shopaddress`,`job`, `last_login`, `create_time`,`wx_user`, `wx_openid`,`status`) values(null,\''.$username.'\',\''.$name.'\',\''.$password.'\',\''.$sex.'\',\''.$shopname.'\',\''.$province.'\',\''.$city.'\',\''.$shopaddress.'\','.$job.',\''.$login_time.'\',\''.$time.'\',\''.$wx_user.'\',\''.$openid.'\',0)');
		$dbconn->showalert("保存成功","dgrecord.php",1);
	}
	else 
	{
		$dbconn->showalert("已存在该用户，请换个手机号重新注册","dgrecord.php",1);
	}
}

;echo '<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>欢迎登录后台管理系统</title>
<link href="css/base.css" rel="stylesheet" type="text/css" />
<link href="css/right.css" rel="stylesheet" type="text/css">
<script src="js/jquery.min.js"></script>
<script src="js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="../user/js/sel.js"   charset="gb2312"></script>
<script src="js/select-ui.min.js"></script>
<script type="text/javascript">
   $(function(){
   		$(\'#submit\').click(function(){
   			if ($(\'#username\').val() == "")
   			{
   				alert("手机号码不能为空！");return false;
   			}
   			if ($(\'#name\').val() == "")
   			{
   				alert("请填写导购姓名！");return false;
   			}
   			if ($(\'#password\').val() == "")
   			{
   				alert("请填写密码！");return false;
   			}
   			if ($(\'#password1\').val() == "")
   			{
   				alert("请确认密码！");return false;
   			}
   			if ($(\'#password1\').val() != $(\'#password\').val())
   			{
   				alert("两次填写的密码不一致！");return false;
   			}
   			if ($(\'#address\').val() == "")
   			{
   				alert("详细地址是用来发放礼品的！不能为空！");return false;
   			}
   			if ($(\'#openid\').val() == "")
   			{
   				alert("微信openid不能为空！领取红包必备，如果不知道，请在微信"客户端"打开导购注册页面注册！");return false;
   			}
   		});
   });
</script>
</head>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li><a href="index.php">首页</a></li>
    <li><a href="dgrecord.php">导购管理</a></li>
    <li>添加</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>导购管理添加</span></div>
  <form name="radd" method="post" action="?act=add">
  <ul class="forminfo">
    <li>
      <label>手机号码</label>
      <input name="username" id="username" type="text" value="" placeholder="用户名" class="dfinput" />
      <i></i></li>
    <li>
      <label>真实姓名</label>
      <input name="name" id="name" type="text" value="" class="dfinput" />
    </li>
    <li>
      <label>密码</label>
      <input name="password" id="password" type="password" value="" class="dfinput" />
    </li>
    <li>
      <label>确认密码</label>
      <input name="password1" id="password1" type="password" value="" class="dfinput" />
    </li>
    <li style="height:35px; line-height:35px;">
      <label>性别</label>
      <div style="border:1px solid #000; width:345px; margin-left:86px;" class="dfinput">
	      <label><input name="sex" type="radio" value="男" checked="checked" />男</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	      <label><input name="sex" type="radio" value="女" />女</label>
      </div>
    </li>
    <li>
      <label>门店名称</label>
      <input name="shopname" id="shopname" type="text" value="" class="dfinput" />
    </li>
    <li>
      <label>省份</label>
      <div style="border:1px;">
      	<select id="selProvince" name="province" onchange="provinceChange();" style="width:347px; height:30px; font-size:14px;border:1px solid green; position:absolute; overflow:hidden"></select>
      </div>
    </li>
    <li>
      <label>城市</label>
      <div style="border:1px;">
      <select id="selCity" name="city" style="width:347px; height:30px; font-size:14px;border:1px solid green; position:absolute; overflow:hidden"></select>
      </div>
    </li>
    <li>
      <label>门店地址</label>
      <textarea name="shopaddress" id="shopaddress" cols="55" rows="4" style="border:1px solid #000;"></textarea>
    </li>
    <li>
    	<label>职位</label>
    		 <div style="border:1px;">
		      	<select name="job" style="width:347px; height:30px; font-size:14px;border:1px solid green; position:absolute; overflow:hidden">
			      	<option value="1">老板</option>
			      	<option value="2">店长</option>
			      	<option value="3">导购</option>
			      	<option value="4">其他</option>
		      	</select>
      		</div>
    </li>
    <li>
      <label>微信号</label>
      <input name="wx_user" id="wx_user" type="text" value="" class="dfinput" />
    </li>
    <li>
      <label>微信Openid</label>
      <input name="openid" id="opneid" type="text" value="" class="dfinput" />
    </li>
   <!--  <li style="height:35px; line-height:35px;">
      <label>审核</label>
      <div style="border:1px solid #000; width:345px; margin-left:86px;" class="dfinput">
	       <label style="width:345px;"><input name="update" id="name" type="checkbox" value="1" /> &nbsp;&nbsp; 审核</label>
      </div>
    </li>-->
    <li>
      <label>&nbsp;</label>
      <input name="button" type="submit" class="btn" id="submit" value="确认保存"/>
    </li>
  </ul>
  </form>
</div>
<script type="text/javascript">
	$(function (){
		
	});
</script>
</body>
</html>'
?>